<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-date"></i> 用户管理</el-breadcrumb-item>
                <el-breadcrumb-item>用户集成</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container" v-loading="loading">
            <div>
                <el-row class="mt20">
                    <el-col :span="4"><span>是否启用用户集成：</span></el-col>
                    <el-col :span="6">
                        <el-radio v-model="openFlag" label="true">是</el-radio>
                        <el-radio v-model="openFlag" label="false">否</el-radio>
                    </el-col>
                </el-row>
                <el-row class="mt20">
                    <el-col :span="4"><span>用户验证程序包：</span></el-col>
                    <el-col :span="6"><el-input placeholder="cux_user_validate_pub.validate_login" v-model="packageName"></el-input></el-col>
                </el-row>
                <div class="btn-container">
                    <el-button type="primary" @click="handleClick" :loading="btnloading">确定</el-button>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import { mapState } from 'vuex';
export default {
    data() {
        return {
            openFlag:"false",
            packageName:"",
            loading: true,
            btnloading: false
        }
    },
    computed: mapState({
        msg: state => state.user.msg,
        info: state => state.user.info
    }),
    mounted() {
        if(localStorage.getItem('pageType') == 0) {
            this.$router.push({ path:'/user' });
        }
        this.getIntegration();
    },
    methods: {
        //获取用户集成信息
        getIntegration() {
            this.$store.dispatch('getIntegrationInfo',{
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                this.loading = false;
                this.openFlag = this.info.openFlag.toString();
                this.packageName = this.info.packageName;
            })
        },
        handleClick() {
            this.btnloading = true;
            this.$store.dispatch('updateIntegration',{
                openFlag: eval(this.openFlag),
                packageName: this.packageName,
                sessionId: localStorage.getItem('sessionId')
            }).then(() => {
                this.btnloading = false;
                this.$message(this.msg);
            })
        }
    }
}
</script>
<style>

</style>


